package com.wdj.provider.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.wdj.dubboapi.entity.MUserBook;
import com.wdj.dubboapi.service.MUserBookService;
import com.wdj.provider.dao.MUserBookDao;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * (MUserBook)表服务实现类
 *
 * @author makejava
 * @since 2020-07-06 11:52:21
 */
@Service(interfaceClass = MUserBookService.class)
@Component
public class MUserBookServiceImpl implements MUserBookService {
    @Resource
    private MUserBookDao mUserBookDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public MUserBook queryById(Integer id) {
        return this.mUserBookDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<MUserBook> queryAllByLimit(int offset, int limit) {
        return this.mUserBookDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param mUserBook 实例对象
     * @return 实例对象
     */
    @Override
    public MUserBook insert(MUserBook mUserBook) {
        this.mUserBookDao.insert(mUserBook);
        return mUserBook;
    }

    /**
     * 修改数据
     *
     * @param mUserBook 实例对象
     * @return 实例对象
     */
    @Override
    public MUserBook update(MUserBook mUserBook) {
        this.mUserBookDao.update(mUserBook);
        return this.queryById(mUserBook.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.mUserBookDao.deleteById(id) > 0;
    }
}